2 player switch turn different score
Hey guys,
I am building a dart counter. But i have a few questions about it.
How can i make a number keybord with a blank box.
And when I press enter the number goes from the total score, of one of the players.
After pressing enter, how can i make the turn switch?
Sorry for my really bad English ,
PRRP
Best Answer
-
tatiang Posts: 11,949
Make an integer attribute called game.playerTurn and set it to 1. It will switch between 1 and 2. Make two more integer attributes called game.player1Score and game.player2Score. Make a text attribute called game.keyboardInput.
If touch is pressed
Keyboard Input [prompt: "Enter a number"] attribute game.keyboardInputIf game.keyboardInput ≠ ""
If game.playerTurn=1
Change attribute game.player1Score to game.player1Score-game.keyboardInput
If game.playerTurn=2
Change attribute game.player2Score to game.player2Score-game.keyboardInput
Change attribute game.playerTurn to 3-game.playerTurn
Change attribute game.keyboardInput to ""New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
I want to build an app that counts my score when i am darting in real life.
I already made two scores but i want a way of typing in my score. ( like this: )
How can I make that work, because there are two different scores?
@tatiang Thanks!
One more question.
Are we talking about darts as in throwing darts at a dart board?
Can you give me an example of how a round might go? Does each player start with a certain number of points and then subtract points each turn? Sorry, I'm not that familiar with darts.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Darts is a... unique game Someone sat down one day and said "I'm going to make a game that people will mostly play drunk, or at least with a pint in their hand. For the scoring, I'll make them subtract, add and multiply numbers of up to three digits at every opportunity, and put the numbers in a seemingly random order!"
At least that's what I like to believe.
http://www.darts.org.nz/dart-scoring.htm
(Rules will vary ofc, but this is the key points.)
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Lol @Armelline, looks like I have some learning to do!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
With a numeric keypad like that, you have to find a way to "build" the number. If you wanted to key in 43, you can't just add 4+3. You either have to add a factor of ten (410^1+310^0) or concatenate text ("4".."3"). I'd probably do the latter. Someone probably already has a demo of this...
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
In short, a person throws three darts each round. Each dart can hit one of 20 wedges. Within that wedge, it can hit single, double or triple score. So if you hit the 5 wedge, you score will be 5, 10 or 15 depending on where you hit. You can also hit the outer center ring for 25 points or the inner ring for 50 points.
So the lowest showing dart possible is 1, and the highest is 60.
These scores are then deducted from the total (501 by the linked rules) and the first player to reach 0 (and meet a "win" condition if one is required), wins.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Hey,
I made my number pad! and its working.
But at darts you can throw a maximum of 180 at 1 turn. So could i set
the maximum of my text input to 180?
I'd recommend you put a rule that says "If inputted number > 180, change inputted number to 180". Trying to limit the input itself would be very problematic.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
At witch atribute i have to adjust that?
stupid question
Witch condition i have to add?
Whichever one you're storing the inputted score in.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
What I added to my text box actor:
Rule
attribute
but i dont know what to select after 'if'
I think you're going to need to explain a little about how you set up the number pad. When you press a number, what happens (in the logic)?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
You guys have been busy! I made a demo but I'm not sure you need it any more. It limits entry to 2 digits.
http://forums.gamesalad.com/discussion/comment/516905/#Comment_516905
Edit: oops, just noticed you're using PC Creator* and I made the demo in Mac Creator. Carry on...
*I should be getting Windows 8 set up in a day or two so no more lame excuses for me
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
" alt="" title="" />
This are my rules. but it didn't work
thanks @tatiang for your help.
indeed, the number pad is working but there are a few things that aren't.
The way I did this was to make the input a text attribute and the rule for adding a digit (pressing a button) limited to textLength(game.input) < 2, or for your needs, < 3. It would take more sophisticated rules to limit the score to 180. And the enter button should change game.currentPlayer to 3-game.currentPlayer, assuming that game.currentPlayer starts with a value of 1.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
This is my text box at the moment:
" alt="" title="" />
What should i change?
it works fine now, only not with the turnes
at the first 'change attribute' in the second box is standing: game.score1-game.keyboardinput
@tatiang
I understand what you did with the enter button, but i can't make it work. can you explain it a little more.
" alt="" title="" />
this are my Game attributes. How can i make the turn switch work with this attributes?
As I explained above, you use an attribute set to 1 and subtract it from 3 each time the enter button is pressed. This might look strange but mathematically it works like this:
If it is player 1's turn and you press the enter button, the next player will be 3-1=2.
If it is player 2's turn and you press the enter button, the next player will be 3-2=1.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User